<?php

interface IService
{
    public function getReleaseArtists();
    public function getReleaseTitle();
    public function getTracklist();
}

define('META_LABEL', 1 << 0);
define('META_RELEASE_DATE', 1 << 1);
define('META_GENRES', 1 << 2);
define('META_CATALOG', 1 << 3);
define('META_REVIEW', 1 << 4);
define('META_TRACK_BPM', 1 << 5);




function getPage($url) {
    $ch = curl_init();
    $ua = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2';
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, $ua); 
    curl_setopt($ch, CURLOPT_URL, $url);
    return curl_exec($ch);
    curl_close($this->descriptor);
}

function registerModules($folder) {
    $registeredModules = array();
    $it = new DirectoryIterator($folder);
    foreach ($it as $file) {
        if (! $file->isDot()) {
            require_once $folder . '/' . $file->getFilename();
            
            $fn = pathinfo($file->getFilename())['filename'];
            $class = 'Service_' . $fn;
            
            $mask = 0;
            foreach($class::$metaFields as $field) {
                $mask |= $field;
            }
            
            $registeredModules[] = array(
                'id' => $fn,
                'fileName' => $folder . '/' . $file->getFilename(),
                'author' => $class::$author,
                'version' => $class::$version,
                'name' => $class::$moduleName,
                'site' => $class::$site,
                'mask' => $class::$mask,
                'meta' => $mask
            );
        }
    }
    return $registeredModules;
}

function zeros($number, $to) {
    return str_pad((string)$number, $to, '0', STR_PAD_LEFT);
}